<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .btn-red {
      background-color: red;
    }

    .btn-blue {
      background-color: green;
    }

    #btn {
      width: 200px;
      height: 200px;
    }
  </style>
</head>

<body>
  <button class="btn-red" id="btn">点击改变颜色</button>
  <script>
    btn.addEventListener('click', (e) => {
      e.target.className = e.target.className === 'btn-red' ? 'btn-blue' : 'btn-red'
    })
  </script>
</body>

</html>